﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;

    public class PetConfig extends Object
    {
        private var _map:Dictionary;
        private static var _instance:PetConfig;

        public function PetConfig()
        {
            this._map = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" PetConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TPetConfig = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TPetConfig();
                _loc_2.code = _loc_3.code;
                _loc_2.name = _loc_3.name;
                _loc_2.level = _loc_3.level;
                _loc_2.type = _loc_3.type;
                _loc_2.model = _loc_3.model;
                _loc_2.avatar = _loc_3.avatar;
                _loc_2.growth = _loc_3.growth;
                _loc_2.talent = _loc_3.talent;
                _loc_2.talentMax = _loc_3.talentMax;
                _loc_2.skill1 = _loc_3.skill1;
                _loc_2.skill2 = _loc_3.skill2;
                _loc_2.skill3 = _loc_3.skill3;
                _loc_2.selfEffect = _loc_3.selfEffect;
                this._map[_loc_2.code] = _loc_2;
            }
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_pet_config.json");
            this.write(_loc_1);
            return;
        }// end function

        public function getInfoByCode(param1:int) : TPetConfig
        {
            return this._map[param1] as TPetConfig;
        }// end function

        public static function get instance() : PetConfig
        {
            if (_instance == null)
            {
                _instance = new PetConfig;
            }
            return _instance;
        }// end function

    }
}
